<!DOCTYPE html>
<html lang="en">
<head>
	<title>填写预约单</title>
	<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=1, user-scalable=no" charset="UTF-8">
	<link rel="stylesheet" href="android_asset://css/style.css"/>
    <link rel="stylesheet" href="android_asset://css/font.css"/>
</head>
<body>
	<div id="change_date">
		<form class="form-horizontal" id="form"  style="position: relative;" action="/tickets/{{ticketId}}/appoint">
			<input type="hidden" name="action" value="appoint"> 
			<input type="hidden" name="ticketid" value="{{ticketId}}"> 
			<div class="form-group clearfix">
			    <div class="content">
			    	<label  class="left control-label">请求人</label>
			    	<div class="right">
			    		<p>{{ticketEx.customername}}</p>
			    	</div>
		    	</div>
		  	</div>
		  	<div class="form-group clearfix">
		  	    <div class="content">
			    	<label  class="left control-label">联系电话</label>
			    	<div class="right">
			    	  {% if ticketEx.customermobile is not null %}
			    		<a href="javascript:;" class="form-control call" onclick="msAndroid.call('{{ticketEx.customermobile}}')">{{ticketEx.customermobile}}</a>
			    	  {% elseif ticketEx.customerphone is not null %}
			    	    <a href="javascript:;" onclick="msAndroid.call('{{ticketEx.customerphone}}')" class="form-control call">{{ticketEx.customerphone}}</a>
			    	  {% endif %}
			    	</div>
		    	</div>
		  	</div>
		  	{% if ticketEx.customerphone is not null and ticketEx.customermobile is not null %}
		  	<div class="form-group clearfix">
		  	    <div class="content">
			    	<label  class="left control-label"></label>
			    	<div class="right">
			    		<a href="javascript:;" onclick="msAndroid.call('{{ticketEx.customerphone}}')" class="form-control call">{{ticketEx.customerphone}}</a>
			    	</div>
		    	</div>
		  	</div>
            {% endif %}
		  	<div class="form-group clearfix">
		  		<div class="content content_table">
			    	<span class="table_title"><label  class="left control-label">羲和地址</label></span>
			    	<div class="right table_right">
				     	<p>{{ticketEx.customeraddress}}</p>
			    	</div>
			    </div>
		  	</div>
		  	<div class="form-group clearfix">
		    	<div class="content">
			    	<label  class="left control-label">预约到场时间</label>
			   		<div class="right bug_right" style="width: 60%">
			   			<span class="icon-rightarrow right blick_icon"></span>
			   			{% if ticketEx.appointment is not null%}
			    		<input type="text" required onclick="msAndroid.datePicker(this,'#pendingtime')" class="form-control blick_input" readonly="readonly"  placeholder="设定预约到场时间" value="">
			    		<input type="hidden" name="pendingtime" id="pendingtime">
			    		{% else %}
			    		<input type="text" required onclick="msAndroid.datePicker(this,'#appointment')" class="form-control blick_input" readonly="readonly"  placeholder="设定预约到场时间" value="">
			    		<input type="hidden" name="appointment" id="appointment">
			    		{% endif %}
			    	</div>
		    	</div>
		  	</div>
		  	<div class="form-group clearfix">
		    	<div class="content">
			    	<label  class="left control-label">事前提醒</label>
			    	<div class="right bug_right" style="width: 60%">
			   			<span class="icon-rightarrow right blick_icon"></span>
				     	<input type="text" required class="form-control timeRemindText  blick_input" readonly="readonly"  placeholder="设置提醒时间" onclick="timeremind(this,'#timeRemind')" >
				     	<input type="hidden" id="timeRemind" name="remindTime">
			    	</div>
		    	</div>
		  	</div>
		  	<div class="form-group clearfix">
		    	<div class="content">
			    	<label  class="left control-label">上门地址</label>
			    	<div class="right address setUP">
			     		<span class="icon-rightarrow right"></span>
				     	<textarea name="address" required id="location" class="form-control" readonly="readonly"  placeholder="设置上门地址" onclick="msAndroid.location('#location','#lat','#long')">
				     	</textarea>
			    	    <input type="hidden" id="lat" name="latitude">
			    	    <input type="hidden" id="long" name="longitude">
			    	</div>
		    	</div>
		  	</div>

		  	<div class="form-group leo">
		  	    <div class="content">
			    	<label class="control-label">随手记</label>
			    	<div class="describe">
						<textarea name="pendingcause"  cols="30" rows="5" style="width:100%"></textarea>
			    	</div>
		    	</div>
		  	</div>
		</form>

		<div class="confirm">
			<button type="button" class="btn  but"><a href="javascript:;">确认</a></button>
		</div>
	</div>
</body>
<script src="android_asset://jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="android_asset://jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="android_asset://bridge.js" type="text/javascript"></script>
<script src="android_asset://android.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function(){
  	  $('button.but').on('keydown touchstart', function () {
		  $(this).css("background", '#216cb9');
	  });
	  $('button.but').on('keyup touchend', function () {
	      $(this).css("background", '#3e8ddd');
	  });
    	
    	
    	
    	//上门地址换行
		var elem=$("#location"); 
		if(elem.val().length>12){
			$(".setUP").css("line-height","2em");
			elem.css("padding-top",".7em");
		}else{
			$(".setUP").css("line-height","1em");
			elem.css("padding-top","1em");
		}
		
 	   $(".confirm .btn").click(function(){
 	   	 var btn = this;
 		 var flag=false;
 		 $("#form [required]").each(function(){
			  if($.trim($(this).val())==''){
				  msAndroid.toast($(this).attr("placeholder"));
				  flag=true;
				  return false;
			  }
 		 });
 		 if(flag){
 			 return;
 		 }
 		 //检查事前提醒
 		 var remindeDescr = $('#timeRemind').val();
 		 var remindeMinutes = 0;
 		 if(remindeDescr.indexOf("30分钟") != -1) {
 		 	remindeMinutes = 30;
 		 }else if(remindeDescr.indexOf("1小时") != -1) {
 		 	remindeMinutes = 60;
 		 }else if(remindeDescr.indexOf("2小时") != -1) {
 		 	remindeMinutes = 120;
 		 }else if(remindeDescr.indexOf("4小时") != -1) {
 		 	remindeMinutes = 240;
 		 }
 		 //预约到场时间
 		 if(remindeMinutes > 0) {
 		 	var choosetime;
 		 	{% if ticketEx.appointment is not null%}
 		 		choosetime = $('#pendingtime').val();
 		 	{% else %}
 		 		choosetime = $('#appointment').val();
 		 	{% endif %}
 		 	choosetime = choosetime.replace(/-/g,"/");
 		 	choosetime = new Date(choosetime);
 		 	choosetime.setTime(choosetime.getTime()-1000*remindeMinutes*60);
 		 	if(choosetime < new Date()) {
 		 		msAndroid.toast("提醒时间不能早于当前时间");
				return;
 		 	}
 		 }
 		 
 		 var json=msAndroid.changedTicketVO("#form");
 		 var url=$("#form").attr("action");
 		 msAndroid.post(url,json,"put","active",function(jsonResult){
 		 	btn.disabled = false;
 		 });
 		 //禁止页面二次提交
 		 btn.disabled = true;
 	   });
    });
</script>
</html>